package com.lyj.hello.config;

import com.lyj.hello.HelloService;
import com.lyj.hello.HelloServiceProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动装配类
 * @author:liyajie
 * @createTime:2022/1/26 14:23
 * @version:1.0
 */
@Configuration
@ConditionalOnClass(HelloService.class)
@EnableConfigurationProperties(HelloServiceProperties.class)
public class HelloServiceAutoConfiguration {
    @Autowired
    private HelloServiceProperties helloServiceProperties;

    @Bean
    public HelloService helloService(){
        return new HelloService(helloServiceProperties.getSuffix(), helloServiceProperties.getSuffix());
    }
}
